package com.ali.stock.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ali.stock.domain.SysEntrust;
import com.ali.stock.service.SysEntrustService;
import com.ali.stock.mapper.SysEntrustMapper;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
* @author Administrator
* @description 针对表【sys_entrust(委托表)】的数据库操作Service实现
* @createDate 2024-03-26 15:46:18
*/
@Service
public class SysEntrustServiceImpl extends ServiceImpl<SysEntrustMapper, SysEntrust>
    implements SysEntrustService{

    @Override
    public List<SysEntrust> getHistoryEntrustList(Long userId) {
        return this.baseMapper.getHistoryEntrustList(userId);
    }

    @Override
    public List<SysEntrust> getTodayEntrustList(Long userId) {
        return this.baseMapper.getTodayEntrustList(userId);
    }

//    @Override
//    public List<SysEntrust> getTodayEntrustList(Long userId) {
//        List<SysEntrust> historyEntrustList = this.baseMapper.getHistoryEntrustList(userId);
//        List<SysEntrust> sysEntrustList = new ArrayList<>();
//        for (SysEntrust sysEntrust : historyEntrustList) {
//            Date entrustTime = sysEntrust.getEntrustTime();
////            DateUtil.
//            Calendar calendar = Calendar.getInstance(); // 获取当前日期和时间
//            calendar.add(Calendar.DAY_OF_MONTH, -1); // 将日期向前推一天
//            Date oneDayAgo = calendar.getTime(); // 获取推算后的日期
//            if(entrustTime.compareTo(oneDayAgo)<0 && sysEntrust.getEntrustStatus().equals("已报")){
//                sysEntrustList.add(sysEntrust);
//            }
//        }
//        return sysEntrustList;
//    }
}




